package xyz.zhouzhaodong.crm.controller;


import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import xyz.zhouzhaodong.crm.dto.DepartmentDto;
import xyz.zhouzhaodong.crm.entity.Department;
import xyz.zhouzhaodong.crm.service.IDepartmentService;
import xyz.zhouzhaodong.crm.util.NoRepeatSubmit;
import xyz.zhouzhaodong.crm.util.RestMessage;

import javax.annotation.Resource;

/**
 * <p>
 * 部门表 前端控制器
 * </p>
 *
 * @author zhouzhaodong
 * @since 2020-06-10
 */
@RestController
@RequestMapping("/department")
public class DepartmentController {

    @Resource
    IDepartmentService departmentService;

    /**
     * 新增
     * @param departmentDto
     * @return
     */
    @NoRepeatSubmit
    @RequestMapping("/add")
    public RestMessage add(DepartmentDto departmentDto){
        return departmentService.addDepartment(departmentDto);
    }

    /**
     * 删除
     * @param id
     * @param staffId
     * @return
     */
    @RequestMapping("/delete")
    public RestMessage delete(String id, String staffId){
        return departmentService.deleteDepartment(id, staffId);
    }

    /**
     * 修改
     * @param departmentDto
     * @return
     */
    @RequestMapping("/update")
    public RestMessage update(DepartmentDto departmentDto){
        return departmentService.updateDepartment(departmentDto);
    }

    /**
     * 根据id查询部门
     * @param id
     * @return
     */
    @RequestMapping("/selectOne")
    public RestMessage selectOne(String id){
        return departmentService.selectOne(id);
    }

    /**
     * 根据条件查询列表
     * @param departmentDto
     * @return
     */
    @RequestMapping("/selectList")
    public RestMessage selectList(DepartmentDto departmentDto){
        return departmentService.selectList(departmentDto);
    }

}
